import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:study/list/PingLun.dart';
import 'package:study/list/listdata.dart';
import 'package:study/page/PingLun.dart';

class Settingpage extends StatefulWidget {
  @override
  _SettingpageState createState() => _SettingpageState();
}

class _SettingpageState extends State<Settingpage>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    _controller = AnimationController(vsync: this);
    super.initState();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }




  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body:
          Swiper(
            itemBuilder: (BuildContext context, int index) {
              //淡入淡出
              return Padding(
                padding: EdgeInsets.all(20),
                child: Stack(
                  children: <Widget>[
                    Container(
                      width: MediaQuery.of(context).size.width / 1.1,
                      height:  MediaQuery.of(context).size.height / 1.1,
                      child: Image.network(
                        listData[index]["imageUrl"],
                        fit: BoxFit.cover,
                      ),
                    ),
                    Center(
                      child: Text(listData[index]["title"],style: TextStyle(
                          color: Colors.white,
                          fontSize: 40,
                          fontWeight: FontWeight.w700
                      ),),
                    )
                  ],
                ),
              );
            },
            scrollDirection: Axis.horizontal,
            itemCount: listData.length,
            itemWidth: MediaQuery.of(context).size.width,
            itemHeight: MediaQuery.of(context).size.height,
            layout: SwiperLayout.TINDER,
            onTap: (index) => {
              showDialog(
                  context: context,
                  builder: (context) => AlertDialog(
                    title: Text(listData[index]["title"]),
                    content: Text(listData[index]["description"]),
                    actions: <Widget>[
                      new FlatButton(
                        child: new Text("看评论"),
                        onPressed: () {
                          Navigator.of(context).pop();
                          showDialog(
                              context: context,
                              builder: (context) => AlertDialog(
                                title: Container(
                                  child:
                                  ListTile(
                                    leading: CircleAvatar(
                                      backgroundImage: NetworkImage(pinglun[index]["url"]),
                                    ),
                                    title: Text(pinglun[index]["name"]),
                                    subtitle: Text(pinglun[index]["text"]),
                                  ),
                                ),
                                actions: <Widget>[
                                  new FlatButton(
                                    child: new Text("说两句"),
                                    onPressed: () {

                                      Navigator.of(context).push(
                                          MaterialPageRoute(builder: (context)=>PingLunPage())
                                      );

                                    },
                                  ),
                                ],
                              ));

                        },
                      ),
                    ],
                  )),
            },
          ),
    );

    /* SizedBox(
      width: 400.0,
      height: 400.0,
      child: Shimmer.fromColors(
        baseColor: Colors.red,
        highlightColor: Colors.green,

        child: Text(
          '世界非物质文化遗产',
          textAlign: TextAlign.center,
          style: TextStyle(
            fontSize: 40.0,
            fontWeight:
            FontWeight.bold,
          ),
        ),
      ),
    );*/
  }
}
